finding the greatest common factor